﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace AllTalkProxy
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IAllTalkProxyService
    {
        [OperationContract]
        ConnectionResult Connect(ConnectionParameters connectionParams);

        [OperationContract]
        void Send(string senderJid, string xmlStaza);
        // TODO: Add your service operations here

        [OperationContract]
        void GetVcard(string senderJid, string[] friends);

        [OperationContract(AsyncPattern = true)]
        IAsyncResult BeginReceiveMessagesAndPresence(string senderJid, AsyncCallback callback, object state);

        ServerUpdate EndReceiveMessagesAndPresence(IAsyncResult asyncResult);
    }

    [DataContract]
    public class ConnectionParameters
    {
        [DataMember]
        public string Username { get; set; }

        [DataMember]
        public string Password { get; set; }

        [DataMember]
        public string Domain { get; set; }

    }

    [DataContract]
    public class ConnectionResult
    {
        [DataMember]
        public string Jid { get; set; }

        [DataMember]
        public string RosterXml { get; set; }

        [DataMember]
        public List<string> PresenceXml { get; set; }
    }

    [DataContract]
    public class ServerUpdate
    {
        [DataMember]
        public List<string> PresenceXml { get; set; }

        [DataMember]
        public List<string> MessageXml { get; set;}

        [DataMember]
        public List<Vcard> VcardXml { get; set; }
    }

    [DataContract]
    public class Vcard
    {
        [DataMember]
        public string Xml { get; set; }

        [DataMember]
        public string UserId { get; set; }
    }
}
